<?php

/**
 * Contact form base class.
 *
 * @method Contact getObject() Returns the current form's model object
 *
 * @package    docplus.co.za
 * @subpackage form
 * @author     Fox Matuku
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseContactForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                     => new sfWidgetFormInputHidden(),
      'user_id'                => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'add_empty' => false)),
      'home_phone'             => new sfWidgetFormInputText(),
      'work_phone'             => new sfWidgetFormInputText(),
      'mobile_phone'           => new sfWidgetFormInputText(),
      'mobile_activation_code' => new sfWidgetFormInputText(),
      'alternate_email'        => new sfWidgetFormInputText(),
      'street_address'         => new sfWidgetFormTextarea(),
      'post_code'              => new sfWidgetFormInputText(),
      'area'                   => new sfWidgetFormInputText(),
      'city_id'                => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('City'), 'add_empty' => false)),
      'region_id'              => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Region'), 'add_empty' => false)),
      'created_at'             => new sfWidgetFormDateTime(),
      'updated_at'             => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                     => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'user_id'                => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('User'))),
      'home_phone'             => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'work_phone'             => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'mobile_phone'           => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'mobile_activation_code' => new sfValidatorString(array('max_length' => 10, 'required' => false)),
      'alternate_email'        => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'street_address'         => new sfValidatorString(array('max_length' => 500, 'required' => false)),
      'post_code'              => new sfValidatorString(array('max_length' => 10, 'required' => false)),
      'area'                   => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'city_id'                => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('City'))),
      'region_id'              => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Region'))),
      'created_at'             => new sfValidatorDateTime(),
      'updated_at'             => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('contact[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Contact';
  }

}
